package l1j.server.server.model.skill;

import static l1j.server.server.model.skill.L1SkillId.*;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;

import l1j.opqlo.O_SkillSound;
import l1j.opqlo.NewSystem.L1AI_Check;
import l1j.opqlo.NewSystem.L1AttackCancel;
import l1j.opqlo.NewSystem.各項記錄輸出;
import l1j.opqlo.NewSystem.LABA.L1LaBa;
import l1j.opqlo.Server.L1World.L1World;
import l1j.server.Config;
import l1j.server.server.datatables.ItemTable;
import l1j.server.server.datatables.SkillsTable;
import l1j.server.server.datatables.SprTable;
import l1j.server.server.model.L1Character;
import l1j.server.server.model.L1EffectSpawn;
import l1j.server.server.model.L1Inventory;
import l1j.server.server.model.L1PolyMorph;
import l1j.server.server.model.L1Teleport;
import l1j.server.server.model.Instance.L1GuardInstance;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.model.Instance.L1MonsterInstance;
import l1j.server.server.model.Instance.L1NpcInstance;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.model.Instance.L1PetInstance;
import l1j.server.server.model.Instance.L1SummonInstance;
import l1j.server.server.serverpackets.S_ChatPacket;
import l1j.server.server.serverpackets.S_CurseBlind;
import l1j.server.server.serverpackets.S_Dexup;
import l1j.server.server.serverpackets.S_HPUpdate;
import l1j.server.server.serverpackets.S_Liquor;
import l1j.server.server.serverpackets.S_MPUpdate;
import l1j.server.server.serverpackets.S_NPCTalkReturn;
import l1j.server.server.serverpackets.S_OwnCharAttrDef;
import l1j.server.server.serverpackets.S_OwnCharStatus;
import l1j.server.server.serverpackets.S_PacketBox;
import l1j.server.server.serverpackets.S_Paralysis;
import l1j.server.server.serverpackets.S_PinkName;
import l1j.server.server.serverpackets.S_Poison;
import l1j.server.server.serverpackets.S_RemoveObject;
import l1j.server.server.serverpackets.S_SPMR;
import l1j.server.server.serverpackets.S_ServerMessage;
import l1j.server.server.serverpackets.S_SkillBrave;
import l1j.server.server.serverpackets.S_SkillHaste;
import l1j.server.server.serverpackets.S_SkillIconAura;
import l1j.server.server.serverpackets.S_SkillIconBlessOfEva;
import l1j.server.server.serverpackets.S_SkillIconShield;
import l1j.server.server.serverpackets.S_SkillIconThirdSpeed;
import l1j.server.server.serverpackets.S_SkillIconWindShackle;
import l1j.server.server.serverpackets.S_SkillIconWisdomPotion;
import l1j.server.server.serverpackets.S_SkillSound;
import l1j.server.server.serverpackets.S_Sound;
import l1j.server.server.serverpackets.S_Strup;
import l1j.server.server.serverpackets.S_SystemMessage;
import l1j.server.server.templates.L1Skills;
import l1j.server.server.utils.Random;
import l1j.server.server.utils.StreamUtil;
import l1j.server.server.utils.Teleportation;

/*
 * XXX 2008/02/13 vala 本来、このクラスはあるべきではないが暫定処置。
 * 2008/02/13 VALA，本來不應該存在這個類，但臨時處理。
 */
public class L1SkillStop {
	private static Logger _log = Logger.getLogger(L1SkillStop.class.getName());
	private static final int S_OPCODE_GLOBALCHAT = 106;// メッセージの表示（終了するとき）

	private static void sendStopMessage(final L1PcInstance charaPc,
			final int skillid) {
		final L1Skills l1skills = SkillsTable.getInstance().getTemplate(skillid);
		if (l1skills == null || charaPc == null) {
			return;
		}
		final int msgID = l1skills.getSysmsgIdStop();
		if (msgID > 0) {
			charaPc.sendPackets(new S_ServerMessage(msgID));
		}
	}

	public static void stopSkill(final L1Character cha, final int skillId) {
		try {

			if (skillId == LIGHT) { // ライト
				if (cha instanceof L1PcInstance) {
					if (!cha.isInvisble()) {
						final L1PcInstance pc = (L1PcInstance) cha;
						pc.turnOnOffLight();
					}
				}
				/**opqlo 檢查身上是否有到期須刪除的物品*/
			} else if(skillId == checkDeleteItem){
				final L1PcInstance pc = (L1PcInstance) cha;
				pc.getInventory().isHaveDeleteItem();
				pc.setSkillEffect(skillId, 60000);
				return;
			} else if(skillId == TELEPORT_DELAY){//瞬移異常解鎖
				final L1PcInstance pc = (L1PcInstance) cha;
				Teleportation.actionTeleportation(pc);
				pc.sendPackets(new S_SystemMessage("偵測到網路異常，重新執行瞬移動作。"));
			} else if (skillId == EXP_UP) {
				final L1PcInstance pc = (L1PcInstance) cha;
				pc.getExpRate = 1;
				pc.sendPackets(new S_SystemMessage("經驗加倍狀態結束。"));
				pc.save();
			} else if(skillId >= 無種族 && skillId <= 龍族){
				final int type = skillId-14180;
				final L1PcInstance pc = (L1PcInstance) cha;
				pc.addEthncityDmg(type, -0.4);
				String msg = "";
				switch(type){
				case	0	://戰鬥藥水-無種族
					msg = "無種族";
					break;
				case	1	://戰鬥藥水-不死族
					msg = "不死族";
					break;
				case	2	://戰鬥藥水-惡魔族
					msg = "惡魔族";
					break;
				case	3	://戰鬥藥水-頭目族
					msg = "頭目族";
					break;
				case	4	://戰鬥藥水-亡靈族
					msg = "亡靈族";
					break;
				case	5	://戰鬥藥水-狼族
					msg = "狼族";
					break;
				case	6	://戰鬥藥水-龍族
					msg = "龍族";
					break;
				}
				pc.sendPackets(new S_SystemMessage("對"+msg+"攻擊恢復正常。"));
				pc.sendPackets(new S_SkillSound(pc.getId() , 427));
			} else if (skillId == 法術增傷){
				final L1PcInstance pc = (L1PcInstance) cha;
				pc.addMagicDmgModfier(-100);
				pc.sendPackets(new S_SkillSound(pc.getId() , 427));
				pc.sendPackets(new S_SystemMessage("法術增傷恢復正常。"));
			} else if (skillId == Laba_START) {// opqlo 海賊王拉霸
				final L1PcInstance pc = (L1PcInstance) cha;
				if (cha instanceof L1PcInstance) {
					pc.sendPackets(new S_SystemMessage("目前總彩金已累計【"+L1LaBa.gettotalprize()+"】 商城元寶，祝您中獎。"));
					final O_SkillSound effect = new O_SkillSound(pc.getId(),6410);
					pc.sendPackets(effect);// opqlo 拉霸開始動畫
					// pc.broadcastPacket(effect);//opqlo 展示用
					pc.setSkillEffect(Laba_END, 4000);
				}
			} else if (skillId == Laba_END) {// opqlo 海賊王拉霸
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					final L1LaBa laba = new L1LaBa();
					laba.LabaStart(pc);
				}
			}else if (skillId == ATTRACT_MONSTER){
				final L1PcInstance pc = (L1PcInstance) cha;
				pc.sendPackets(new S_SystemMessage("\\aD身上氣味逐漸淡去，怪物對你失去興趣。"));
				pc.sendPacketsX8(new S_SkillSound(pc.getId(),4229));
			} else if(skillId == TELEPORT_PROTECTION){
				final L1PcInstance pc = (L1PcInstance) cha;
				pc.sendPackets(new S_SystemMessage("結界保護效果消失，PVP狀態開啟。"));
			} else if (skillId == 惡魔的香水) {
				final L1PcInstance pc = (L1PcInstance) cha;
				pc.addDroprate(-0.5);
				pc.add金幣率(-0.5);
				pc.sendPackets(new S_SystemMessage("\\aH撒旦與你的交易已經終止。"));
				pc.sendPacketsX8(new S_SkillSound(pc.getId(), 422));
				pc.sendPacketsX8(new S_SkillSound(pc.getId(), 437));
			} else if (skillId == 加速器檢測) {
				final L1PcInstance pc = (L1PcInstance) cha;
				BufferedWriter out = null;
				try {
					final TimeZone tz = TimeZone.getTimeZone(Config.TIME_ZONE);
					final Calendar cal = Calendar.getInstance(tz);
					final int year = cal.get(Calendar.YEAR) - 2000;
					final StringBuilder timer = new StringBuilder()
					.append(year).append("-")
					.append(cal.get(Calendar.MONTH) + 1).append("-")
					.append(cal.get(Calendar.DATE));
					out = new BufferedWriter(new FileWriter(
							Config.LOG_LOCATION+"記錄/加速器檢測/" + pc.getName() + "檢測紀錄"+ timer.toString() + ".txt", true));
					out.write(pc.msg
							.append(new Timestamp(System.currentTimeMillis()))
							.append("\r\n▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇\r\n")
							.toString());
					timer.delete(0, timer.length());
				} catch (final Exception e) {
				} finally {
					StreamUtil.close(out);
				}
				if (pc.msg != null) {
					pc.msg.delete(0, pc.msg.length());
					pc.msg = null;
				}
			}else if(skillId ==人參雞湯){
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMaxHp(-pc.getExtraHp());
					pc.addMaxMp(-pc.getExtraMp());
					pc.setExtraHp(0);
					pc.setExtraMp(0);
					pc.sendPackets(new S_HPUpdate(pc.getCurrentHp(), pc.getMaxHp()));
					if (pc.isInParty()) { // パーティー中
						pc.getParty().updateMiniHP(pc);
					}
					pc.sendPackets(new S_MPUpdate(pc.getCurrentMp(), pc.getMaxMp()));
					pc.sendPackets(new S_SystemMessage("人參雞湯效果結束。"));
					pc.sendPackets(new S_SkillSound(pc.getId() , 2427));
				}
			}else if(skillId == 烏骨雞湯){
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SystemMessage("烏骨雞湯效果結束。"));
					pc.sendPackets(new S_SkillSound(pc.getId() , 2426));
				}
			}else if(skillId == 蒜頭雞湯){
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SystemMessage("蒜頭雞湯效果結束。"));
					pc.sendPackets(new S_SkillSound(pc.getId() , 2425));
				}
//			} else if (skillId == 戰鬥月餅 || skillId == 防禦月餅) {
//				if (cha instanceof L1PcInstance) {
//					final L1PcInstance pc = (L1PcInstance) cha;
//					pc.sendPackets(new S_SystemMessage("\\aF月餅效果結束。"));
//				}
			} else if (skillId == 狂暴打擊) {
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc._CastleweaponSkillDmg = 0;
					pc._CastleMagicModDmg = 0;
					pc.sendPackets(new S_SystemMessage("\\aF狂暴打擊的效果已經消失。"));
					pc.sendPackets(new S_SkillSound(pc.getId(), 418));
					pc.sendPackets(new S_Sound(9805));
				}
			} else if (skillId == 鋼鐵防禦) {
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc._CastleDmgReduction = 0;
					pc._CastleExtraDef = 0;
					pc.sendPackets(new S_SystemMessage("\\aF鋼鐵防禦的效果已經消失。"));
					pc.sendPackets(new S_SkillSound(pc.getId(), 419));
					pc.sendPackets(new S_Sound(9806));
				}
			} else if (skillId == 賞金獵人) {
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc._CastleDropRate = 0;
					pc.sendPackets(new S_SkillSound(pc.getId(), 5763));
					pc.sendPackets(new S_SystemMessage("\\aF賞金獵人的效果已經消失。"));
					pc.sendPackets(new S_Sound(9807));
				}
			} else if (skillId == 狩獵專長) {
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc._CastleExpRate = 0;
					pc.sendPackets(new S_SkillSound(pc.getId(), 424));
					pc.sendPackets(new S_SystemMessage("\\aF狩獵專長的效果已經消失。"));
					pc.sendPackets(new S_Sound(9808));
				}
			} else if (skillId == 98765432) {
				final L1PcInstance pc = (L1PcInstance) cha;
				final String chatText[] = { "對不起，GM我錯了", "我是大笨豬", "我下次不敢亂GM了",
						"@#%%^&^#^%@$@#", "GM大人饒命!!", "大家都說大牛比較懶" };
				final S_ChatPacket s_chatpacket = new S_ChatPacket(pc,chatText[Random.nextInt(chatText.length)],S_OPCODE_GLOBALCHAT, 0);
				if (!pc.getExcludingList().contains(pc.getId())) {
					pc.sendPackets(s_chatpacket);
					pc.broadcastPacketAll(s_chatpacket);
					pc.setSkillEffect(98765432, 3000);
				}
			} else if (skillId == PC_IsPinkName) {// opqlo 修正紫名更新問題
				final L1PcInstance pc = (L1PcInstance) cha;
				final int mapid = pc.getMapId();
				if(mapid != 1813){
					if (pc.isPinkName()) {
						pc.setPinkName(false);
					}
				}else{
					pc.setSkillEffect(skillId, 180000);//opqlo 修正紫名更新問題
					pc.sendPacketsAll(new S_PinkName(pc.getId(), 180));
				}
			} else if (skillId == STATUS_THIRD_SPEED2) { // 4段加速
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.setBraveSpeed(0);
					pc.setThirdSpeed(0);
					pc.setMoveSpeed(0);
					final int pcid = pc.getId();
					final S_SkillBrave Brave = new S_SkillBrave(pcid, 0, 0);
					pc.sendPackets(Brave);
					pc.broadcastPacketAll(Brave);
				}
			} else if (skillId == STATUS_THIRD_SPEED3) { // 4.5段加速
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					final int pcid = pc.getId();
					// 四段加速移除
					final S_Liquor Liquor = new S_Liquor(pcid, 0);
					pc.sendPackets(Liquor); // 人物 * 1.15
					pc.broadcastPacketAll(Liquor); // 人物 * 1.15
					pc.sendPackets(new S_SkillIconThirdSpeed(0));
					pc.setSpeedUp(false);

					// 三段加速移除
					pc.setMoveSpeed(0);
					pc.setBraveSpeed(0);
					pc.setThirdSpeed(0);
					final S_SkillBrave Brave = new S_SkillBrave(pcid, 0, 0);
					pc.sendPackets(Brave);
					pc.broadcastPacketAll(Brave);
				}
			} else if (skillId == STATUS_THIRD_SPEED4
					|| skillId == STATUS_THIRD_SPEED) { // 5段加速、3段加速
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					final int pcid = pc.getId();
					// 五段加速移除
					pc.setMoveSpeed(0);
					pc.setSpeedUp(false);
					pc.setBraveSpeed(0);
					pc.setThirdSpeed(0);
					final S_SkillHaste Haste = new S_SkillHaste(pcid, 0, 0);
					pc.sendPackets(Haste);
					pc.broadcastPacketAll(Haste);
					// 四段加速移除
					final S_Liquor Liquor = new S_Liquor(pcid, 0);
					pc.sendPackets(Liquor); // 人物 * 1.15
					pc.broadcastPacketAll(Liquor); // 人物 * 1.15
					pc.sendPackets(new S_SkillIconThirdSpeed(0));
					// 三段加速移除
					final S_SkillBrave Brave = new S_SkillBrave(pcid, 0, 0);
					pc.sendPackets(Brave);
					pc.broadcastPacketAll(Brave);
				}
			} else if (skillId == AI_CheckEffect) {// opqlo 增加掛機判斷問答系統
				final L1PcInstance pc = (L1PcInstance) cha;
				if (cha instanceof L1PcInstance && !pc.isPrivateShop()
						&& Config.AI) {
					final int time = 30000;

					switch (pc.getMapId()) {

					case 5300:
					case 5301:
					case 1784:
					case 340:
					case 350:
					case 370: // 無A.I.檢測
						pc.setSkillEffect(AI_CheckEffect, time);
						break;
					default:
						pc.setTeleport(false);
						if (pc.isParalyzed() || pc.isGhost() || pc.isDead()) {
							pc.setSkillEffect(AI_CheckEffect, 5000);
							return;
						}
						L1AttackCancel.removeSkill(pc);// 清除所有控場技

						pc.setMapXY(pc.getX(), pc.getY(), pc.getMapId());
						L1Teleport.teleportByMagic(pc, 32748, 32787, (short) 3, 5,true);
						pc.setCurrentHp(pc.getMaxHp());
						pc.sendPackets(new S_SkillSound(pc.getId(), 830));
						pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_STUN,true));
						pc.setSkillEffect(SHOCK_STUN, time);
						pc.setSkillEffect(ABSOLUTE_BARRIER, time);
						final int rndo = Random.nextInt(8999) + 1001;
						pc.setSuper(rndo);
						pc._qai = 2;
						pc.setSkillEffect(AI_TimeEffect, time);// 設定回答時間300秒
						pc.sendPackets(new S_SystemMessage("\\fP請輸入：【 A" + String.valueOf(rndo)+ " 】並按下Enter確認！"));
						final String msg[] = { "隨機系統提問：", "AI外掛檢測程序啟動！", " ",
								"請輸入下方的文字" , " " , "驗證碼:  A" + rndo ,  " ",
								"請於30秒之內完成答題！", "回答錯誤 3次", "超過時間會被踢下線！" };
						pc.sendPackets(new S_NPCTalkReturn(pc.getId(),"AI_Cheack21", msg));
						break;
					}
				}
			} else if (skillId == AI_TimeEffect) {
				final L1PcInstance pc = (L1PcInstance) cha;
				if (cha instanceof L1PcInstance) {
					L1AI_Check.AI_kick(pc);
				}

				// 增加掛機判斷問答系統END

			} else if (skillId == PointDelay) {
				final L1PcInstance pc = (L1PcInstance) cha;
				boolean log = false;
				final StringBuilder msg = new StringBuilder().append("玩家:[ ")
						.append(pc.getName()).append(" ]時間: ")
						.append(new Timestamp(System.currentTimeMillis()));
				for (int i = 0; i < 3; i++) {
					final L1ItemInstance item = ItemTable.getInstance()
							.createItem(pc.PointId[i]);
					if (item != null) {
						final int count = pc.PointCount[i];
						item.setCount(count);
						if (pc.getInventory().checkAddItem(item, count) == L1Inventory.OK) {
							pc.getInventory().storeItem(item);
							pc.sendPackets(new S_ServerMessage(403, item
									.getLogName()));
							pc.PointId[i] = 0;
							pc.PointCount[i] = 0;
							msg.append("領取獎勵[ ").append(item.getViewName())
							.append(" ]");
							log = true;

						} else { // 持てない場合は地面に落とす 處理のキャンセルはしない（不正防止）
							// L1World.getInstance().getInventory(pc.getX(),
							// pc.getY(), pc.getMapId()).storeItem(item);
							pc.sendPackets(new S_SystemMessage(
									"系統於10秒後重新發放獎勵，請整理背包。"));
							pc.setSkillEffect(14144, 10000);
						}
					}
				}
				if (log) {
					各項記錄輸出.LogSave(18, msg.toString());
				}
				msg.delete(0, msg.length());
			} else if (skillId == BONE_BREAK) {// 骷髏毀壞
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_STUN, false));
					pc.setParalyzed(false);
				} else if (cha instanceof L1MonsterInstance
						|| cha instanceof L1SummonInstance
						|| cha instanceof L1PetInstance) {
					final L1NpcInstance npc = (L1NpcInstance) cha;
					npc.setParalyzed(false);
				}
			} else if (skillId == GLOWING_AURA) { // グローウィング オーラ
				cha.addHitup(-5);
				cha.addBowHitup(-5);
				cha.addMr(-20);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SPMR(pc));
					pc.sendPackets(new S_SkillIconAura(113, 0));
				}
			} else if (skillId == SHINING_AURA) { // シャイニング オーラ
				cha.addAc(8);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(114, 0));
				}
			} else if (skillId == BRAVE_AURA) { // ブレイブ オーラ
				cha.addDmgup(-5);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(116, 0));
				}
			} else if (skillId == SHIELD) { // シールド
				cha.addAc(2);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconShield(5, 0));
				}
			} else if (skillId == BLIND_HIDING) { // ブラインドハイディング
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.delBlindHiding();
				}
			} else if (skillId == SHADOW_ARMOR) { // シャドウ アーマー
				cha.addAc(3);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconShield(3, 0));
				}
			} else if (skillId == DRESS_DEXTERITY) { // ドレス デクスタリティー
				cha.addDex((byte) -2);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Dexup(pc, 2, 0));
				}
				// TODO 暗影閃避 鏡像byajackk2001
			} else if (skillId == UNCANNY_DODGE) { // TODO 暗影閃避
				cha.addDodge((byte) -5); // TODO 閃避率 - 50%
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(88, pc.getDodge()));
				}
			} else if (skillId == MIRROR_IMAGE) { // TODO 鏡像
				cha.addDodge((byte) -5); // TODO 閃避率 - 50%
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(88, pc.getDodge()));
					// TODO 暗影閃避 鏡像byajackk2001
				}
			} else if (skillId == DRESS_MIGHTY) { // ドレス マイティー
				cha.addStr((byte) -2);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Strup(pc, 2, 0));
				}
			} else if (skillId == SHADOW_FANG) { // シャドウ ファング
				cha.addDmgup(-5);
			} else if (skillId == ENCHANT_WEAPON) { // エンチャント ウェポン
				cha.addDmgup(-2);
			} else if (skillId == BLESSED_ARMOR) { // ブレスド アーマー
				cha.addAc(3);
			} else if (skillId == EARTH_BLESS) { // アース ブレス
				cha.addAc(7);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconShield(7, 0));
				}
			} else if (skillId == RESIST_MAGIC) { // レジスト マジック
				cha.addMr(-10);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SPMR(pc));
				}
			} else if (skillId == CLEAR_MIND) { // クリアー マインド
				cha.addWis((byte) -3);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.resetBaseMr();
				}
			} else if (skillId == RESIST_ELEMENTAL) { // レジスト エレメント
				cha.addWind(-10);
				cha.addWater(-10);
				cha.addFire(-10);
				cha.addEarth(-10);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_OwnCharAttrDef(pc));
				}
			} else if (skillId == ELEMENTAL_PROTECTION) { // エレメンタルプロテクション
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					final int attr = pc.getElfAttr();
					if (attr == 1) {
						cha.addEarth(-50);
					} else if (attr == 2) {
						cha.addFire(-50);
					} else if (attr == 4) {
						cha.addWater(-50);
					} else if (attr == 8) {
						cha.addWind(-50);
					}
					pc.sendPackets(new S_OwnCharAttrDef(pc));
				}
			} else if (skillId == ELEMENTAL_FALL_DOWN) { // エレメンタルフォールダウン
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					final int attr = pc.getAddAttrKind();
					final int i = 50;
					switch (attr) {
					case 1:
						pc.addEarth(i);
						break;
					case 2:
						pc.addFire(i);
						break;
					case 4:
						pc.addWater(i);
						break;
					case 8:
						pc.addWind(i);
						break;
					default:
						break;
					}
					pc.setAddAttrKind(0);
					pc.sendPackets(new S_OwnCharAttrDef(pc));
				} else if (cha instanceof L1NpcInstance) {
					final L1NpcInstance npc = (L1NpcInstance) cha;
					final int attr = npc.getAddAttrKind();
					final int i = 50;
					switch (attr) {
					case 1:
						npc.addEarth(i);
						break;
					case 2:
						npc.addFire(i);
						break;
					case 4:
						npc.addWater(i);
						break;
					case 8:
						npc.addWind(i);
						break;
					default:
						break;
					}
					npc.setAddAttrKind(0);
				}
			} else if (skillId == IRON_SKIN) { // アイアン スキン
				cha.addAc(10);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconShield(10, 0));
				}
			} else if (skillId == EARTH_SKIN) { // アース スキン
				cha.addAc(6);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconShield(6, 0));
				}
			} else if (skillId == PHYSICAL_ENCHANT_STR) { // フィジカル エンチャント：STR
				cha.addStr((byte) -5);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Strup(pc, 5, 0));
				}
			} else if (skillId == PHYSICAL_ENCHANT_DEX) { // フィジカル エンチャント：DEX
				cha.addDex((byte) -5);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Dexup(pc, 5, 0));
				}
			} else if (skillId == FIRE_WEAPON) { // ファイアー ウェポン
				cha.addDmgup(-4);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(147, 0));
				}
			} else if (skillId == FIRE_BLESS) { // ファイアー ブレス
				cha.addDmgup(-4);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(154, 0));
				}
			} else if (skillId == BURNING_WEAPON) { // バーニング ウェポン
				cha.addDmgup(-6);
				cha.addHitup(-3);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(162, 0));
				}
			} else if (skillId == BLESS_WEAPON) { // ブレス ウェポン
				cha.addDmgup(-2);
				cha.addHitup(-2);
				cha.addBowHitup(-2);
			} else if (skillId == WIND_SHOT) { // ウィンド ショット
				cha.addBowHitup(-6);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(148, 0));
				}
			} else if (skillId == STORM_EYE) { // ストーム アイ
				cha.addBowHitup(-2);
				cha.addBowDmgup(-3);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(155, 0));
				}
			} else if (skillId == STORM_SHOT) { // ストーム ショット
				cha.addBowDmgup(-200);
				cha.addBowHitup(-50);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconAura(165, 0));
				}
			} else if (skillId == BERSERKERS) { // バーサーカー
				cha.addAc(-10);
				cha.addDmgup(-5);
				cha.addHitup(-2);
			} else if (skillId == SHAPE_CHANGE) { // シェイプ チェンジ
				L1PolyMorph.undoPoly(cha);
			} else if (skillId == ADVANCE_SPIRIT) { // アドバンスド スピリッツ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMaxHp(-pc.getAdvenHp());
					pc.addMaxMp(-pc.getAdvenMp());
					pc.setAdvenHp(0);
					pc.setAdvenMp(0);
					pc.sendPackets(new S_HPUpdate(pc.getCurrentHp(), pc.getMaxHp()));
					if (pc.isInParty()) { // パーティー中
						pc.getParty().updateMiniHP(pc);
					}
					pc.sendPackets(new S_MPUpdate(pc.getCurrentMp(), pc.getMaxMp()));
				}
			} else if (skillId == HASTE || skillId == GREATER_HASTE) { // ヘイスト、グレーターヘイスト
				cha.setMoveSpeed(0);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillHaste(pc.getId(), 0, 0));
					pc.broadcastPacketAll(new S_SkillHaste(pc.getId(), 0, 0));
				}
			} else if (skillId == HOLY_WALK || skillId == MOVING_ACCELERATION
					|| skillId == WIND_WALK ) { // ホーリーウォーク、ムービングアクセレーション、ウィンドウォーク、ブラッドラスト
				cha.setBraveSpeed(0);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillBrave(pc.getId(), 0, 0));
					pc.broadcastPacketAll(new S_SkillBrave(pc.getId(), 0, 0));
				}
			} else if(skillId == BLOODLUST) {
				cha.setBraveSpeed(0);
				cha.setMoveSpeed(0);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillBrave(pc.getId(), 0, 0));
					pc.broadcastPacketAll(new S_SkillBrave(pc.getId(), 0, 0));
				}
			} else if (skillId == ILLUSION_OGRE) { // イリュージョン：オーガ
			} else if (skillId == ILLUSION_LICH) { // イリュージョン：リッチ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SPMR(pc));
				}
			} else if (skillId == ILLUSION_DIA_GOLEM) { // イリュージョン：ダイアモンドゴーレム
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addAc(20);
				}
			} else if (skillId == ILLUSION_AVATAR) { // TODO 幻術師技能幻覺幻身
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SPMR(pc));
				}
			} else if (skillId == INSIGHT) { // インサイト
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addStr(-1);// TODO 力量
					pc.addCon(-1);// TODO 體質
					pc.addDex(-1);// TODO 敏捷
					pc.addWis(-1);// TODO 精神
					pc.addInt(-1);// TODO 智力
				}
			} else if (skillId == PANIC) {// TODO 實裝幻術師恐慌by0968026609
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addStr(1);// TODO 力量
					pc.addCon(1);// TODO 體質
					pc.addDex(1);// TODO 敏捷
					pc.addWis(1);// TODO 精神
					pc.addInt(1);// TODO 智力
				}
			}

			// ****** 状態変化が解けた場合
			else if (skillId == CURSE_BLIND || skillId == DARKNESS) {
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_CurseBlind(0));
				}
			} else if (skillId == CURSE_PARALYZE) { // カーズ パラライズ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Poison(pc.getId(), 0));
					pc.broadcastPacketAll(new S_Poison(pc.getId(), 0));
					pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_PARALYSIS,
							false));
				}
			} else if (skillId == WEAKNESS) { // ウィークネス
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addDmgup(5);
					pc.addHitup(1);
				}
			} else if (skillId == DISEASE) { // ディジーズ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addDmgup(6);
					pc.addAc(-12);
				}
			} else if (skillId == ICE_LANCE // アイスランス
					|| skillId == FREEZING_BLIZZARD // フリージングブリザード
					|| skillId == FREEZING_BREATH
					|| skillId == NPC_FREEZING_BREATH) { // フリージングブレス
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Poison(pc.getId(), 0));
					pc.broadcastPacketAll(new S_Poison(pc.getId(), 0));
					pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_FREEZE,false));
					pc.setParalyzed(false);
				} else if (cha instanceof L1MonsterInstance
						|| cha instanceof L1SummonInstance
						|| cha instanceof L1PetInstance) {
					final L1NpcInstance npc = (L1NpcInstance) cha;
					npc.broadcastPacketAll(new S_Poison(npc.getId(), 0));
					npc.setParalyzed(false);
				}
			} else if (skillId == EARTH_BIND) { // アースバインド
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Poison(pc.getId(), 0));
					pc.broadcastPacketAll(new S_Poison(pc.getId(), 0));
					pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_FREEZE,false));
					pc.setParalyzed(false);
				} else if (cha instanceof L1MonsterInstance
						|| cha instanceof L1SummonInstance
						|| cha instanceof L1PetInstance) {
					final L1NpcInstance npc = (L1NpcInstance) cha;
					npc.broadcastPacketAll(new S_Poison(npc.getId(), 0));
					npc.setParalyzed(false);
				}
			} else if (skillId == SHOCK_STUN) { // ショック スタン
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_STUN, false));
					pc.setParalyzed(false);
				} else if (cha instanceof L1MonsterInstance
						|| cha instanceof L1SummonInstance
						|| cha instanceof L1PetInstance) {
					final L1NpcInstance npc = (L1NpcInstance) cha;
					npc.setParalyzed(false);
				}
			} else if (skillId == FOG_OF_SLEEPING) { // フォグ オブ スリーピング
				cha.setSleeped(false);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_SLEEP,
							false));
					pc.sendPackets(new S_OwnCharStatus(pc));
				}
			} else if (skillId == ABSOLUTE_BARRIER) { // アブソルート バリア
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.startHpRegeneration();
					pc.startMpRegeneration();
					pc.startMpRegenerationByDoll();
					pc.startHpRegenerationByDoll();
				}
			} else if (skillId == WIND_SHACKLE) { // ウィンド シャックル
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconWindShackle(pc.getId(), 0));
				}
			} else if (skillId == SLOW || skillId == ENTANGLE
					|| skillId == MASS_SLOW) { // スロー、エンタングル、マススロー
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillHaste(pc.getId(), 0, 0));
					pc.broadcastPacketAll(new S_SkillHaste(pc.getId(), 0, 0));
				}
				cha.setMoveSpeed(0);
			} else if (skillId == STATUS_FREEZE) { // Freeze
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_BIND, false));
				} else if (cha instanceof L1MonsterInstance
						|| cha instanceof L1SummonInstance
						|| cha instanceof L1PetInstance) {
					final L1NpcInstance npc = (L1NpcInstance) cha;
					npc.setParalyzed(false);
					npc.setPassispeed(npc.getNpcTemplate().get_passispeed());
				}else if (cha instanceof L1GuardInstance){
					final L1NpcInstance npc = (L1NpcInstance)cha;
					if(npc.isParalyzed()){
						npc.setParalyzed(false);
					}else{
						final int objId = npc.getId();
						npc.broadcastPacketAll(new S_SkillBrave(objId, 5, 0));
						npc.broadcastPacketAll(new S_SkillHaste(objId, 1, 0));
						npc.broadcastPacketAll(new S_SkillSound(objId, 751));
						npc.broadcastPacketAll(new S_SkillSound(objId, 755));
						npc.setSkillEffect(巡守變身, 7000);
					}
					npc.setPassispeed(npc.getNpcTemplate().get_passispeed());
				}
			}else if (skillId == 巡守變身){
				if (cha instanceof L1GuardInstance){
					final L1NpcInstance npc = (L1NpcInstance)cha;
					npc.setTempCharGfx(539);
					npc.setPassispeed(SprTable.getInstance().getMoveSpeed(539, 0));
					npc.broadcastPacketAll(new S_SkillSound(npc.getId(), 436));
					for (final L1PcInstance pc : L1World.getInstance().getRecognizePlayer(npc)) {
						pc.sendPackets(new S_RemoveObject(npc));
						pc.removeKnownObject(npc);
						pc.updateObject();
					}
				}
			} else if (skillId == THUNDER_GRAB_START) {
				final L1Skills _skill = SkillsTable.getInstance().getTemplate(THUNDER_GRAB); // 奪命之雷
				final int _fetterDuration = _skill.getBuffDuration() * 1000;
				cha.setSkillEffect(STATUS_FREEZE, _fetterDuration);
				L1EffectSpawn.getInstance().spawnEffect(81182, _fetterDuration,cha.getX(), cha.getY(), cha.getMapId(), null);

			} else if (skillId == GUARD_BRAKE) { // ガードブレイク
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addAc(-15);
				}
			} else if (skillId == HORROR_OF_DEATH) { // ホラーオブデス
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addStr(5);
					pc.addInt(5);
				}
			} else if (skillId == STATUS_CUBE_IGNITION_TO_ALLY) { // キューブ[イグニション]：味方
				cha.addFire(-30);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_OwnCharAttrDef(pc));
				}
			} else if (skillId == STATUS_CUBE_QUAKE_TO_ALLY) { // キューブ[クエイク]：味方
				cha.addEarth(-30);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_OwnCharAttrDef(pc));
				}
			} else if (skillId == STATUS_CUBE_SHOCK_TO_ALLY) { // キューブ[ショック]：味方
				cha.addWind(-30);
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_OwnCharAttrDef(pc));
				}
			} else if (skillId == STATUS_CUBE_IGNITION_TO_ENEMY) { // キューブ[イグニション]：敵
			} else if (skillId == STATUS_CUBE_QUAKE_TO_ENEMY) { // キューブ[クエイク]：敵
			} else if (skillId == STATUS_CUBE_SHOCK_TO_ENEMY) { // キューブ[ショック]：敵
			} else if (skillId == STATUS_MR_REDUCTION_BY_CUBE_SHOCK) { // キューブ[ショック]によるMR減少
			} else if (skillId == Online_Bonus) { // TODO 在線一段時間給物品 by 阿傑
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					final L1ItemInstance item = ItemTable.getInstance().createItem(Config.GI);
					int count = Config.GIC;
					if (pc.isVIP) {
						count *= 1.5;
					}
					item.setCount(count);
					if (item != null) {
						if (pc.getInventory().checkAddItem(item, 1) == L1Inventory.OK) {
							pc.getInventory().storeItem(item);
						}
						pc.sendPackets(new S_ServerMessage(403, item.getLogName())); // %0を手に入
						pc.getNetConnection().getAccount().addOnlineTime();//更新在線時間
					}
				}
				cha.setSkillEffect(Online_Bonus, Config.GIT * 60000);// 3分鐘
				return;
				// TODO 在線一段時間給物品 by 阿傑
			} else if (skillId == STATUS_CUBE_BALANCE) { // キューブ[バランス]
			}

			// ****** アイテム関係
			else if (skillId == STATUS_BRAVE || skillId == STATUS_ELFBRAVE) { // ブレイブポーション等
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillBrave(pc.getId(), 0, 0));
					pc.broadcastPacketAll(new S_SkillBrave(pc.getId(), 0, 0));
				}
				cha.setBraveSpeed(0);
			} else if (skillId == STATUS_RIBRAVE) { // ユグドラの実
				if (cha instanceof L1PcInstance) {
				}
				cha.setBraveSpeed(0);
			} else if (skillId == STATUS_HASTE) { // グリーン ポーション
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillHaste(pc.getId(), 0, 0));
					pc.broadcastPacketAll(new S_SkillHaste(pc.getId(), 0, 0));
				}
				cha.setMoveSpeed(0);
			} else if (skillId == STATUS_BLUE_POTION) { // ブルー ポーション
			} else if (skillId == STATUS_UNDERWATER_BREATH) { // エヴァの祝福＆マーメイドの鱗
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_SkillIconBlessOfEva(pc.getId(), 0));
				}
			} else if (skillId == STATUS_WISDOM_POTION) { // ウィズダム ポーション
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					cha.addSp(-2);
					pc.sendPackets(new S_SkillIconWisdomPotion(0));
				}
			} else if (skillId == STATUS_CHAT_PROHIBITED) { // チャット禁止
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_ServerMessage(288)); // チャットができるようになりました。
				}
			}

			// ****** 毒関係
			else if (skillId == STATUS_POISON) { // ダメージ毒
				cha.curePoison();
			}
			// TODO 暗影閃避 鏡像byajackk2001
			else if (skillId == MIRROR_IMAGE || skillId == UNCANNY_DODGE) { // TODO
				// 鏡像、暗影閃避
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addDodge((byte) 5); // TODO 閃避率 - 50%
					pc.sendPackets(new S_PacketBox(88, pc.getDodge()));
				}
			}
			// TODO 暗影閃避 鏡像byajackk2001

			// ****** 料理関係
			else if (skillId == COOKING_1_0_N || skillId == COOKING_1_0_S) { // フローティングアイステーキ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addWind(-10);
					pc.addWater(-10);
					pc.addFire(-10);
					pc.addEarth(-10);
					pc.sendPackets(new S_OwnCharAttrDef(pc));
					pc.sendPackets(new S_PacketBox(53, 0, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_1_1_N || skillId == COOKING_1_1_S) { // ベアーステーキ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMaxHp(-30);
					pc.sendPackets(new S_HPUpdate(pc.getCurrentHp(), pc
							.getMaxHp()));
					if (pc.isInParty()) { // パーティー中
						pc.getParty().updateMiniHP(pc);
					}
					pc.sendPackets(new S_PacketBox(53, 1, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_1_2_N || skillId == COOKING_1_2_S) { // ナッツ餅
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 2, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_1_3_N || skillId == COOKING_1_3_S) { // 蟻脚のチーズ焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addAc(1);
					pc.sendPackets(new S_PacketBox(53, 3, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_1_4_N || skillId == COOKING_1_4_S) { // フルーツサラダ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMaxMp(-20);
					pc.sendPackets(new S_MPUpdate(pc.getCurrentMp(), pc
							.getMaxMp()));
					pc.sendPackets(new S_PacketBox(53, 4, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_1_5_N || skillId == COOKING_1_5_S) { // フルーツ甘酢あんかけ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 5, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_1_6_N || skillId == COOKING_1_6_S) { // 猪肉の串焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMr(-5);
					pc.sendPackets(new S_SPMR(pc));
					pc.sendPackets(new S_PacketBox(53, 6, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_1_7_N || skillId == COOKING_1_7_S) { // キノコスープ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 7, 0));
					pc.setDessertId(0);
				}
			} else if (skillId == COOKING_2_0_N || skillId == COOKING_2_0_S) { // キャビアカナッペ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 8, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_2_1_N || skillId == COOKING_2_1_S) { // アリゲーターステーキ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMaxHp(-30);
					pc.sendPackets(new S_HPUpdate(pc.getCurrentHp(), pc
							.getMaxHp()));
					if (pc.isInParty()) { // パーティー中
						pc.getParty().updateMiniHP(pc);
					}
					pc.addMaxMp(-30);
					pc.sendPackets(new S_MPUpdate(pc.getCurrentMp(), pc
							.getMaxMp()));
					pc.sendPackets(new S_PacketBox(53, 9, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_2_2_N || skillId == COOKING_2_2_S) { // タートルドラゴンの菓子
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addAc(2);
					pc.sendPackets(new S_PacketBox(53, 10, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_2_3_N || skillId == COOKING_2_3_S) { // キウィパロット焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 11, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_2_4_N || skillId == COOKING_2_4_S) { // スコーピオン焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 12, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_2_5_N || skillId == COOKING_2_5_S) { // イレッカドムシチュー
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMr(-10);
					pc.sendPackets(new S_SPMR(pc));
					pc.sendPackets(new S_PacketBox(53, 13, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_2_6_N || skillId == COOKING_2_6_S) { // クモ脚の串焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addSp(-1);
					pc.sendPackets(new S_SPMR(pc));
					pc.sendPackets(new S_PacketBox(53, 14, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_2_7_N || skillId == COOKING_2_7_S) { // クラブスープ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 15, 0));
					pc.setDessertId(0);
				}
			} else if (skillId == COOKING_3_0_N || skillId == COOKING_3_0_S) { // クラスタシアンのハサミ焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 16, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_3_1_N || skillId == COOKING_3_1_S) { // グリフォン焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMaxHp(-50);
					pc.sendPackets(new S_HPUpdate(pc.getCurrentHp(), pc
							.getMaxHp()));
					if (pc.isInParty()) { // パーティー中
						pc.getParty().updateMiniHP(pc);
					}
					pc.addMaxMp(-50);
					pc.sendPackets(new S_MPUpdate(pc.getCurrentMp(), pc
							.getMaxMp()));
					pc.sendPackets(new S_PacketBox(53, 17, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_3_2_N || skillId == COOKING_3_2_S) { // コカトリスステーキ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 18, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_3_3_N || skillId == COOKING_3_3_S) { // タートルドラゴン焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addAc(3);
					pc.sendPackets(new S_PacketBox(53, 19, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_3_4_N || skillId == COOKING_3_4_S) { // レッサードラゴンの手羽先
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMr(-15);
					pc.sendPackets(new S_SPMR(pc));
					pc.addWind(-10);
					pc.addWater(-10);
					pc.addFire(-10);
					pc.addEarth(-10);
					pc.sendPackets(new S_OwnCharAttrDef(pc));
					pc.sendPackets(new S_PacketBox(53, 20, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_3_5_N || skillId == COOKING_3_5_S) { // ドレイク焼き
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addSp(-2);
					pc.sendPackets(new S_SPMR(pc));
					pc.sendPackets(new S_PacketBox(53, 21, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_3_6_N || skillId == COOKING_3_6_S) { // 深海魚のシチュー
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.addMaxHp(-30);
					pc.sendPackets(new S_HPUpdate(pc.getCurrentHp(), pc
							.getMaxHp()));
					if (pc.isInParty()) { // パーティー中
						pc.getParty().updateMiniHP(pc);
					}
					pc.sendPackets(new S_PacketBox(53, 22, 0));
					pc.setCookingId(0);
				}
			} else if (skillId == COOKING_3_7_N || skillId == COOKING_3_7_S) { // バシリスクの卵スープ
				if (cha instanceof L1PcInstance) {
					final L1PcInstance pc = (L1PcInstance) cha;
					pc.sendPackets(new S_PacketBox(53, 23, 0));
					pc.setDessertId(0);
				}
			}
		} catch (final Exception e) {
			_log.log(Level.WARNING, e.getLocalizedMessage(), e);
		}
		if (cha instanceof L1PcInstance) {
			final L1PcInstance pc = (L1PcInstance) cha;
			sendStopMessage(pc, skillId);
			pc.sendPackets(new S_OwnCharStatus(pc));
		}
	}
}
